package com.demo.core.dao.impl;

import java.util.Map;

import com.demo.core.dao.SiteDao;
import com.demo.core.dao.impl.base.BaseCoreDaoSupport;
import com.demo.core.model.Site;
import com.demo.core.model.support.GeneralExecuteModel;

/**
 * 站点数据访问层实现类
 * 
 * @author ryuu.kk
 */
public class SiteDaoImpl extends BaseCoreDaoSupport<Site, Long> implements SiteDao {

	/**
	 * 站点空间 
	 */
	protected final static String SITE_SPACE = "siteSpace.";
	/**
	 * 模型表名
	 */
	protected final static String TABLE_NAME = "T_CORE_SITE";
	/**
	 * 模型表主键ID
	 */
	protected final static String TABLE_PK_NAME = "ID";

	@Override
	public int updateStatus(Site site, Map<String, Object> siteType) {
		cacheClear();
		siteType.put("site", site);
		return getSqlMapClientTemplate().update(SITE_SPACE + "changeSiteStatus", siteType);
	}

	@Override
	public int updateOwner(Site site, Map<String, Object> siteOwnerInfo) {
		cacheClear();
		siteOwnerInfo.put("site", site);
		return getSqlMapClientTemplate().update(SITE_SPACE + "updateSiteOwner", siteOwnerInfo);
	}
	
	@Override
	public int updateSuffix(Site site, Map<String, Object> params) {
		cacheClear();
		params.put("site", site);
		return getSqlMapClientTemplate().update(SITE_SPACE + "changeSiteSuffix", params);
	}
	
	@Override
	public int close(Site site, Map<String, Object> siteParams) {
		cacheClear();
		siteParams.put("site", site);
		return getSqlMapClientTemplate().update(SITE_SPACE + "closeSite", siteParams);
	}

	@Override
	public int updateNestedSet(Map<String, Object> siteParams) {
		cacheClear();
		return getSqlMapClientTemplate().update(SITE_SPACE + "updateNestedSet", siteParams);
	}
	
	@Override
	public Site tree(Map<String, Object> params) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected String nameSpace() {
		return SITE_SPACE;
	}
	@Override
	protected void doInit(GeneralExecuteModel<Long> model) {
		model.setPk(TABLE_PK_NAME);
		model.setTable(TABLE_NAME);
	}
}
